package ae.pcfc.etks.cld.service.manager.provider;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import ae.pcfc.etks.cld.service.common.exception.LookupException;
import ae.pcfc.etks.cld.service.common.vo.UserVO;
import ae.pcfc.etks.cld.service.dao.UserDAO;
import ae.pcfc.etks.cld.service.domain.User;

@Service(value="userManagerImpl")
@Scope("singleton")
public class UserManagerImpl extends BaseManager implements ae.pcfc.etks.cld.service.manager.UserManager{
	
	public UserManagerImpl(){
		
	}
	
	private UserDAO userDAO;
	

	@Autowired
	public UserManagerImpl(UserDAO userDAO){
		this.userDAO = userDAO;
	}
	
	
	@Transactional(readOnly = true)
	public List<UserVO> getUsers() throws LookupException{
		
		List<User> users = userDAO.getUserList();
		List<UserVO> userVOs = new ArrayList<UserVO>();
		
		getMapper().map(userVOs, users);
		
		return (userVOs==null||userVOs.size()<1)?null:userVOs;
	}
	
}
